package logic

import (
	"context"
	"shop/model/mysql"

	"shop/internal/svc"
	"shop/shop"

	"github.com/zeromicro/go-zero/core/logx"
)

type ReservationListLogic struct {
	ctx    context.Context
	svcCtx *svc.ServiceContext
	logx.Logger
}

func NewReservationListLogic(ctx context.Context, svcCtx *svc.ServiceContext) *ReservationListLogic {
	return &ReservationListLogic{
		ctx:    ctx,
		svcCtx: svcCtx,
		Logger: logx.WithContext(ctx),
	}
}

func (l *ReservationListLogic) ReservationList(in *shop.ReservationListRequest) (*shop.ReservationListResponse, error) {
	// todo: add your logic here and delete this line

	var r []mysql.Reservation
	mysql.DB.Find(&r)
	var reservationList []*shop.ReservationList
	for _, k := range r {
		reservationList = append(reservationList, &shop.ReservationList{
			HouseId:         k.HouseId,
			ReservationTime: k.ReservationTime,
			ReservationSn:   k.ReservationSn,
		})
	}
	return &shop.ReservationListResponse{
		List: reservationList,
	}, nil
}
